#if !defined(_ASPRITE_CONTAINER_H_)
#define _ASPRITE_CONTAINER_H_

#include "AObject.h"

class CASprite;

#define NAMED_GROUP_ALL "all-sprites"
class CASpriteContainer
{
protected:
	//named sprites
	CAStringMap<CCArray> _spritesNamed;
	void _addNamedSprite(CASprite* pspr);
	void _removeNamedSprite(CASprite* pspr);
	size_t _getNamedSpritesCount(const char* name = NAMED_GROUP_ALL);
	CCArray* _getNamedSprites(const char* name = NAMED_GROUP_ALL);
	CASprite* _getNamedSprite(const char* name, unsigned int index = 0);

	//add sprite
	CAObjectList<CASprite> _spritesWillBeAttached;
	void _addSprite(CASprite* pspr);
	void _addScheduledSprites();
	
	//remove sprites
	CAObjectList<CASprite> _spritesWillBeRemoved;
	int _removeDiedSprites();
public:
	CASpriteContainer();
	virtual ~CASpriteContainer(void);

	//do not change this function name to addChild
	virtual void addSprite(CASprite* pspr, bool bNow = false);
	virtual void removeSprite(CASprite* pspr);

	virtual void onEnter();
	virtual void onUpdate();
	virtual void onExit();
};

#endif //_ASPRITE_CONTAINER_H_
